package com.wyc.verificationCode.controller;

import com.wyc.internalCommon.response.NumberCodeResponse;
import com.wyc.internalCommon.result.ApiResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NumberCodeController {

    /**
     * 获取验证码
     * @param size
     * @return
     */
    @RequestMapping("/numberCode/{size}")
    public ApiResult getNumberCode(@PathVariable("size") int size){
        int code = (int) ((Math.random()*9 + 1) * Math.pow(10, size-1));
        NumberCodeResponse num = new NumberCodeResponse();
        num.setNumberCode(code);
        return ApiResult.success(num);
    }

}
